#pragma once

#define P1_KEY_UP		0x01
#define P1_KEY_DOWN		0x02
#define P1_KEY_LEFT		0x03
#define P1_KEY_RIGHT	0x04
#define P1_KEY_A		0x05
#define P1_KEY_B		0x06
#define P1_KEY_X		0x07
#define P1_KEY_Y		0x08
#define P1_KEY_L		0x09
#define P1_KEY_R		0x0A
#define P1_KEY_START	0x0B
#define P1_KEY_SELECT	0x0C

#define P2_KEY_UP		0x11
#define P2_KEY_DOWN		0x12
#define P2_KEY_LEFT		0x13
#define P2_KEY_RIGHT	0x14
#define P2_KEY_A		0x15
#define P2_KEY_B		0x16
#define P2_KEY_X		0x17
#define P2_KEY_Y		0x18
#define P2_KEY_L		0x19
#define P2_KEY_R		0x1A
#define P2_KEY_START	0x1B
#define P2_KEY_SELECT	0x1C

#include "cfg.h"

#ifndef CONFIG_FILE_NAME
	#define CONFIG_FILE_NAME "config.ini"
#endif

namespace EngineLib {

	class GameConfig
	{
	private:
		static bool _fullScreen;
		static bool _wideScreen;
		static bool _verticalSync;
		static bool _showFPS;

		static int _musicVolume;
		static int _soundVolume;

		static int _screenWidth;
		static int _screenHeight;
		static int _MSAA;
		static float _gamma;

		static unsigned int _p1JoyStick;
		static unsigned int _p2JoyStick;

		static unsigned char _keyMap[256];
		static unsigned char _defaultKeyMap[32];
		
		static unsigned char _p1JoyMap[32];
		static unsigned char _p2JoyMap[32];
		static unsigned char _defaultP1JoyMap[16];
		static unsigned char _defaultP2JoyMap[16];

		static const unsigned int _typeSystemNameHash;
		static const unsigned int _typeP1KeyNameHash;
		static const unsigned int _typeP2KeyNameHash;
		static const unsigned int _typeP1JoyNameHash;
		static const unsigned int _typeP2JoyNameHash;

		static const unsigned int _fullScreenNameHash;
		static const unsigned int _wideScreenNameHash;
		static const unsigned int _verticalSyncNameHash;
		static const unsigned int _showFPSNameHash;
		
		static const unsigned int _musicVolumeNameHash;
		static const unsigned int _soundVolumeNameHash;
		
		static const unsigned int _screenWidthNameHash;
		static const unsigned int _screenHeightNameHash;
		static const unsigned int _MSAANameHash;
		static const unsigned int _gammaNameHash;

		static const unsigned int _arrowUpNameHash;
		static const unsigned int _arrowDownNameHash;
		static const unsigned int _arrowLeftNameHash;
		static const unsigned int _arrowRightNameHash;
		static const unsigned int _buttonANameHash;
		static const unsigned int _buttonBNameHash;
		static const unsigned int _buttonXNameHash;
		static const unsigned int _buttonYNameHash;
		static const unsigned int _buttonLNameHash;
		static const unsigned int _buttonRNameHash;
		static const unsigned int _startNameHash;
		static const unsigned int _selectNameHash;

	private:
		static void _LoadDefaultKeyAndJoy(void);

	public:
		static bool GetFullScreen(void);
		static void SetFullScreen(bool);

		static bool GetWideScreen(void);
		static void SetWideScreen(bool);
		
		static bool GetVerticalSync(void);
		static void SetVerticalSync(bool);
		
		static bool GetShowFPS(void);
		static void SetShowFPS(bool);
		
		static int GetMusicVolume(void);
		static void SetMusicVolume(int);
		
		static int GetSoundVolume(void);
		static void SetSoundVolume(int);

		static int GetScreenWidth(void);
		static void SetScreenWidth(int);

		static int GetScreenHeight(void);
		static void SetScreenHeight(int);

		static int GetMSAA(void);
		static void SetMSAA(int);

		static float GetGamma(void);
		static void SetGamma(float);

		static unsigned char GetKey(unsigned char key);
		static void SetKey(unsigned char key, unsigned char mapValue);
		static unsigned char GetDefaultKey(unsigned char mapValue);

		static void StartUp(void);
		static void ShutDown(void);

		static void ExtendDefault(void);
		static void LoadDefault(void);

		static void LoadFile(void);
		static void WriteFile(void);
	};

}